package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.request.GetListCompanyRequest;
import keeto.com.vn.bms.network.response.GetListCompanyResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskGetListCompany extends AbstractTask {
	String authenKey;
	
	public TaskGetListCompany(BMSListener listener, IBMSCore core,String authKey) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.authenKey=authKey;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		GetListCompanyRequest request= new GetListCompanyRequest();
		request.setAuthenKey(authenKey);
		GetListCompanyResponse response= protocol.getListCompanies(request);
		for(BMSListener mlistener:listener){
			mlistener.finishGetListCompany(response.getReturnCode(), response.getResultMsg(), response.getListComs());
		}
		
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for(BMSListener mlistener:listener){
			mlistener.finishGetListCompany(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "", null);
		}
		
	}

}
